const express = require("express");
const bodyParser = require("body-parser");
const app = express();
const userRouter = require("./src/api/user/index")
const menuRouter = require("./src/api/menu/index")
const goodSourceRouter = require("./src/api/good/source")
const goodInfoRouter = require("./src/api/good/info")
const goodProductRouter = require("./src/api/good/product")
const goodInspectionRouter = require("./src/api/good/inspection")
const goodRecallRouter = require("./src/api/good/recall")
const roleRouter = require("./src/api/role/index")
const powerRouter = require("./src/api/power/index")
const moveRouter = require("./src/api/move/index")
const logRouter = require("./src/api/log/index")
const supplier = require("./src/api/company/supplier")
const distributor = require("./src/api/company/distributor")
const sgsRouter = require("./src/api/company/sgs")
const noticeRouter = require("./src/api/notice/index")
// 配置中间件
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
// 配制跨域
app.all('*', function (req, res, next) {
    let originHeader=req.headers.origin;
    res.header("Access-Control-Allow-Origin", originHeader);
    // res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By", ' 3.2.1');
    res.header("Content-Type", "application/json;charset=utf-8");
    res.header("Access-Control-Allow-Credentials", true);
    next();
  });
app.use(express.static('./public/'));

app.listen("3009",function(err){
    if(err){
        return
    }
    console.log("服务正常运行")
})

app.use("/fts/user",userRouter)
app.use("/fts/role",roleRouter)
app.use("/fts/power",powerRouter)
app.use("/fts/menu",menuRouter)
app.use("/fts/good",goodInfoRouter)
app.use("/fts/good",goodSourceRouter)
app.use("/fts/good",goodProductRouter)
app.use("/fts/good",goodInspectionRouter)
app.use("/fts/good",goodRecallRouter)
app.use("/fts/move",moveRouter)
app.use("/fts/log",logRouter)
app.use("/fts/busi/sup",supplier)
app.use("/fts/busi/distr",distributor)
app.use("/fts/busi/sgs",sgsRouter)
app.use("/fts/notice",noticeRouter)

